home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / AIFF DSP v22 / main_src / plugin_specific.c < prev    next >
Text File  |  1995-01-30  |  1KB  |  52 lines

  1. /* handles plugin selection & execution */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. #include "aiff.h"
  7. #include "plugin_specific.h"
  8.  
  9. #define DECLARE_PLUGIN( plugin_arg ) extern plugin_info plugin_##plugin_arg;
  10.  
  11. #define MAX_PLUGINS 50
  12.  
  13. DECLARE_PLUGIN( sinegen )
  14. DECLARE_PLUGIN( ringmod )
  15. DECLARE_PLUGIN( view )
  16. DECLARE_PLUGIN( cardread )
  17. DECLARE_PLUGIN( chebyshev )
  18. DECLARE_PLUGIN( zerocross )
  19. DECLARE_PLUGIN( analyze )
  20. DECLARE_PLUGIN( null )
  21.  
  22.  
  23. static plugin_info plugin[MAX_PLUGINS];
  24.  
  25. #define PLUGIN( plugin_arg ) \
  26.    fprintf( stderr, "%d. "#plugin_arg"\n", i ); \
  27.    plugin[i] = plugin_##plugin_arg; \
  28.    i++; \
  29.  
  30. plugin_info *select_plugin( void ) {
  31. #define S_LEN 10
  32.    int i = 0, plugin_num = -1;
  33.    char s[S_LEN];
  34.  
  35.    PLUGIN( ringmod )
  36.    PLUGIN( sinegen )
  37.    PLUGIN( view )
  38.    PLUGIN( cardread )
  39.    PLUGIN( chebyshev )
  40.    PLUGIN( zerocross )
  41.    PLUGIN( analyze )
  42.    PLUGIN( null )
  43.  
  44.    fprintf( stderr, "\nEnter plugin number: (0..%d): ", i-1 );
  45.    fgets( s, S_LEN, stdin );
  46.    sscanf( s, "%d", &plugin_num );
  47.    if ( plugin_num < 0 || plugin_num >= i )
  48.       err( "select_plugin: Invalid plugin number" );
  49.    
  50.    return &(plugin[plugin_num]);
  51. }
  52.